<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Minim : : Delay</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="stylesheet.css" rel="stylesheet" type="text/css">
</head>
<body> 
<center>
<table class="mainTable">
  <tr>
    <td class="header">
    	<span class="indexheader">Minim</span><br/>
    	<span class="indexnavigation">
    		<a href="index.html">core</a> | 
    		<a href="index_ugens.html">ugens</a> | 
    		<a href="index_analysis.html">analysis</a>
    	</span>
    </td>
    <td class="border-left">&nbsp;</td>
  </tr>
  
  <tr>
    <td class="classNavigation">
    	<p class="mainTextName">Delay</p>
    	
       <p class="linkListHeader">Fields</p>
       <p class="linkList">
           
    <a href="delay_field_audio.html" title="where the incoming audio is patched">audio</a><br/>
    
    <a href="delay_field_delamp.html" title="the strength of each repetition compared to the previous. 
 often labeled as feedback on delay units.">delAmp</a><br/>
    
    <a href="delay_field_deltime.html" title="the time for delay between repetitions.">delTime</a><br/>
    
	   </p>
   
    	
       <p class="linkListHeader">Methods</p>
       <p class="linkList">
           
    <a href="delay_method_channelcount.html" title="Returns the number of channels this UGen has been configured to generate.">channelCount ( )</a><br/>
    
    <a href="delay_method_getlastvalues.html" title="Return the last values generated by this UGen. This will most often be
 used by sub-classes when pulling data from their inputs.">getLastValues ( )</a><br/>
    
    <a href="delay_method_patch.html" title="Send the output of this UGen to another UGen, UGenInput, or AudioOutput.">patch ( )</a><br/>
    
    <a href="delay_method_printinputs.html" title="Prints all inputs connected to this UGen (for debugging)">printInputs ( )</a><br/>
    
    <a href="delay_method_samplerate.html" title="Returns the sample rate of this UGen.">sampleRate ( )</a><br/>
    
    <a href="delay_method_setchannelcount.html" title="Let this UGen know how many channels of audio you will be asking it for.">setChannelCount ( )</a><br/>
    
    <a href="delay_method_setdelamp.html" title="Changes the feedback amplification of the echos.">setDelAmp ( )</a><br/>
    
    <a href="delay_method_setdeltime.html" title="Changes the time in between the echos to the value specified.">setDelTime ( )</a><br/>
    
    <a href="delay_method_setsamplerate.html" title="Set the sample rate for this UGen.">setSampleRate ( )</a><br/>
    
    <a href="delay_method_tick.html" title="Generates one sample frame for this UGen.">tick ( )</a><br/>
    
    <a href="delay_method_unpatch.html" title="Unpatch this UGen from an AudioOutput or other UGen.">unpatch ( )</a><br/>
    
	   </p>
   
    </td>
    <td class="mainText border-left">
    	The Delay UGen is used to create delayed repetitions of the input audio.
 One can control the delay time and amplification of the repetition.
 One can also choose whether the repetition is fed back and/or the input is passed through.
    	<p class="memberSectionHeader">Constructors</p>
    	<pre><em>Constructs a Delay. Maximum delay time will be 0.25 seconds,
 amplitude will be 0.5, and feedback will be off.</em>
Delay()
<em>Constructs a Delay. Amplitude will be 0.5 and feedback will be off.</em>
Delay(float maxDelayTime)
<em>Constructs a Delay. Feedback will be off.</em>
Delay(float maxDelayTime, float amplitudeFactor)
<em>Constructs a Delay.</em>
Delay(float maxDelayTime, float amplitudeFactor, boolean feedBackOn)
Delay(float maxDelayTime, float amplitudeFactor, boolean feedBackOn, boolean passAudioOn)
</pre>
    	
   <p class="memberSectionHeader">Parameters</p>
   
        <span class="parameterName">maxDelayTime</span>&nbsp;&mdash;&nbsp;<span class="parameterDescription">float: is the maximum delay time for any one echo and the default echo time.</span><br/>
    
        <span class="parameterName">amplitudeFactor</span>&nbsp;&mdash;&nbsp;<span class="parameterDescription">float: is the amplification factor for feedback and should generally be from 0 to 1.</span><br/>
    
        <span class="parameterName">feedBackOn</span>&nbsp;&mdash;&nbsp;<span class="parameterDescription">float: is a boolean flag specifying if the repetition continue to feed back.</span><br/>
    
        <span class="parameterName">passAudioOn</span>&nbsp;&mdash;&nbsp;<span class="parameterDescription">float: is a boolean value specifying whether to pass the input audio to the output as well.</span><br/>
    
   
    	<p class="memberSectionHeader">Related</p>
    	
    	<p class="memberSectionHeader">Example</p>
    	<pre>/* delayExample&lt;br/>
 * is an example of using the Delay UGen in a continuous sound example.
 * &lt;p>
 * For more information about Minim and additional features, 
 * visit http://code.compartmental.net/minim/
 * &lt;p>
 * author: Anderson Mills&lt;br/>
 * Anderson Mills's work was supported by numediart (www.numediart.org)
 */

// import everything necessary to make sound.
import ddf.minim.*;
import ddf.minim.ugens.*;

// create all of the variables that will need to be accessed in
// more than one methods (setup(), draw(), stop()).
Minim minim;
AudioOutput out;
Delay myDelay;

// setup is run once at the beginning
void setup()
{
  // initialize the drawing window
  size( 512, 200 );

  // initialize the minim and out objects
  minim = new Minim(this);
  out = minim.getLineOut();
  
  // initialize myDelay with continual feedback and audio passthrough
  myDelay = new Delay( 0.4, 0.5, true, true );
  
  // sawh will create a Sawtooth wave with the requested number of harmonics.
  // like with Waves.randomNHarms for sine waves, 
  // you can create a richer sounding sawtooth this way.
  Waveform saw = Waves.sawh( 15 );
  // create the Blip that will be used
  Oscil myBlip = new Oscil( 245.0, 0.3, saw );
  
  // Waves.square will create a square wave with an uneven duty-cycle,
  // also known as a pulse wave. a square wave has only two values, 
  // either -1 or 1 and the duty cycle indicates how much of the wave 
  // should -1 and how much 1. in this case, we are asking for a square 
  // wave that is -1 90% of the time, and 1 10% of the time. 
  Waveform square = Waves.square( 0.9 );
  // create an LFO to be used for an amplitude envelope
  Oscil myLFO = new Oscil( 1, 0.3, square );
  // offset the center value of the LFO so that it outputs 0 
  // for the long portion of the duty cycle
  myLFO.offset.setLastValue( 0.3 );

  myLFO.patch( myBlip.amplitude );
  
  // and the Blip is patched through the delay into the output
  myBlip.patch( myDelay ).patch( out );
}

// draw is run many times
void draw()
{
  // erase the window to dark grey
  background( 64 );
  // draw using a light gray stroke
  stroke( 192 );
  // draw the waveforms
  for( int i = 0; i &lt; out.bufferSize() - 1; i++ )
  {
    // find the x position of each buffer value
    float x1  =  map( i, 0, out.bufferSize(), 0, width );
    float x2  =  map( i+1, 0, out.bufferSize(), 0, width );
    // draw a line from one buffer position to the next for both channels
    line( x1, 50 + out.left.get(i)*50, x2, 50 + out.left.get(i+1)*50);
    line( x1, 150 + out.right.get(i)*50, x2, 150 + out.right.get(i+1)*50);
  }
  
  text( "Delay time is " + myDelay.delTime.getLastValue(), 5, 15 );
  text( "Delay amplitude (feedback) is " + myDelay.delAmp.getLastValue(), 5, 30 );
}

// when the mouse is moved, change the delay parameters
void mouseMoved()
{
  // set the delay time by the horizontal location
  float delayTime = map( mouseX, 0, width, 0.0001, 0.5 );
  myDelay.setDelTime( delayTime );
  // set the feedback factor by the vertical location
  float feedbackFactor = map( mouseY, 0, height, 0.99, 0.0 );
  myDelay.setDelAmp( feedbackFactor );
}
</pre>
    	<p class="memberSectionHeader">Usage</p>
    	Web & Application
    </td>
  </tr>
</table>
</center>
</body>
</html>